package com.fireXXX.job.analysis.crawler.common.job;

import com.fireXXX.job.analysis.crawler.util.JacksonUtil;
import com.fireXXX.job.analysis.data.api.job.Job;
import com.fireXXX.job.analysis.datamgr.service.JobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class JobPersister {

    @Autowired
    private JobService jobService;

    public void persist(List<Job> jobs) {
        System.out.println(JacksonUtil.toJsonStringSafe(jobs));
        for (Job job : jobs) {
            jobService.save(job);
        }
    }

}
